package lanou3g.myfirstapp36kr;
import android.graphics.Bitmap;
import android.graphics.Bitmap.CompressFormat;
import android.graphics.BitmapFactory;

import java.io.ByteArrayOutputStream;
import java.io.IOException;

import cn.bmob.v3.BmobObject;
import cn.bmob.v3.BmobUser;

/**
 * Created by dllo on 16/8/29.
 */
public class MyUser extends BmobUser {
    private String places;
    private String nick;
    private byte[] icon;//用户头像
    public void setIcon(Bitmap bitmap){
        //一个数组输出流,我们之后会把图片输出到该输出流
        //并从该输出流取出byte[]
        ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
        //将图片输出的方法
        bitmap.compress(CompressFormat.PNG,100,byteArrayOutputStream);
        icon = byteArrayOutputStream.toByteArray();
        try {
            byteArrayOutputStream.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
    public Bitmap getIcon(){
        if (icon != null){
            Bitmap bitmap = BitmapFactory.decodeByteArray(icon,0,icon.length);
            return bitmap;
        }
        return null;
    }

    public String getPlaces() {
        return places;
    }

    public void setPlaces(String places) {
        this.places = places;
    }

    public String getNick() {
        return nick;
    }

    public void setNick(String nick) {
        this.nick = nick;
    }
}
